home *** CD-ROM | disk | FTP | other *** search
- function newgame()
- {
- msg.txt = "START!";
- msg.gotoAndPlay(2);
- fondo.slide.gotoAndStop(random(fondo.slide._totalframes) + 1);
- if(temphuman != null)
- {
- bikers[human] = temphuman;
- temphuman = null;
- }
- delete loop.onEnterFrame;
- murder = false;
- mafiamission = false;
- sponsored = false;
- minutes = seconds = milliseconds = 0;
- n = 2;
- while(n <= 1000)
- {
- removeMovieClip(obstacles[n]);
- n++;
- }
- n = 1;
- while(n <= 4)
- {
- removeMovieClip(bikes[n]);
- n++;
- }
- liveplayers = muchbikes;
- usejumper = paused = false;
- obstacles._x = 245;
- obstacles.attachMovie("obstacle",1,1);
- obstacles[1].gotoAndStop("meta");
- obstacles[1].kind = "meta";
- arrived = 0;
- heat.gotoAndStop(1);
- n = 2;
- while(n <= 10)
- {
- obstacles.attachMovie("obstacle",n,n);
- obstacles[n].kind = obstaclekind[random(obstaclekind.length + 1)];
- obstacles[n].gotoAndStop(obstacles[n].kind);
- obstacles[n]._x = obstacles[Number(n - 1)]._x + obstacles[Number(n - 1)]._width + 150;
- if(obstacles[n].kind == "jumper")
- {
- if(usejumper)
- {
- n--;
- }
- else
- {
- usejumper = true;
- }
- }
- n++;
- }
- trackwidth = obstacles._width + 50;
- laps = muchbikes * 2;
- lap = (trackwidth + center * 2 + 10) * laps;
- temp = new Array();
- temp[bikers[human]] = true;
- bars[human].gotoAndStop(bikers[human]);
- n = 1;
- while(n <= 4)
- {
- bars[n]._visible = false;
- n++;
- }
- n = 1;
- while(n <= muchbikes)
- {
- playerstate[n] = "alive";
- xvel[n] = 0;
- keyb[n] = true;
- damage[n] = 0;
- winnercounter[n] = 0;
- kilometer[n] = 0;
- bars[n]._visible = true;
- bikes.attachMovie("biker",n,n);
- bikes[n]._x = 310;
- mode[n] = "ground";
- mytrack[n] = eval("track" + n)._y;
- bikes[n]._y = mytrack[n];
- bars[n].light.dot.dot._xscale = bars[n].light.dot.dot._yscale = 100;
- if(n != human)
- {
- engine[n] = engine[human] * 0.95 + Math.random(5) / 10 - muchplayers / 50;
- m = 0;
- while(m == 0)
- {
- newmodel = random(6) + 1;
- if(!temp[newmodel])
- {
- temp[newmodel] = true;
- m = 1;
- bikers[n] = models[n] = newmodel;
- bars[n].gotoAndStop(newmodel);
- bars[n].light.dot.dot._xscale = bars[n].light.dot.dot._yscale = 80;
- heat[n].model.gotoAndStop(newmodel);
- cauchomodel[n] = 2;
- xtra[n] = "fuel";
- weaponcounter[n] = 1000;
- }
- }
- }
- n++;
- }
- xtraface.gotoAndStop(xtra[human]);
- weaponface.gotoAndStop(weapon[human]);
- engineface.gotoAndStop(motor);
- cauchoface.gotoAndStop(caucho);
- loop.onEnterFrame = function()
- {
- if(!paused)
- {
- milliseconds++;
- if(milliseconds > 60)
- {
- milliseconds = 0;
- seconds++;
- if(seconds > 60)
- {
- seconds = 0;
- minutes++;
- if(minutes > 60)
- {
- minutes = 0;
- }
- }
- }
- if(milliseconds < 10)
- {
- showmilliseconds = "0" + milliseconds;
- }
- else
- {
- showmilliseconds = milliseconds;
- }
- if(seconds < 10)
- {
- showseconds = "0" + seconds;
- }
- else
- {
- showseconds = seconds;
- }
- if(minutes < 10)
- {
- showminutes = "0" + minutes;
- }
- else
- {
- showminutes = minutes;
- }
- showtime = showminutes + ":" + showseconds + ":" + milliseconds;
- if(keyb[human] != false)
- {
- if(key.isDown(39))
- {
- xvel[human] += engine[human];
- bikes[human].gotoAndStop(1);
- if(motorstarted == false)
- {
- motorstarted = true;
- motorsnd.start(0,9999);
- }
- }
- else if(key.isDown(37))
- {
- if(kilometer[human] > -10)
- {
- xvel[human] -= engine[human];
- bikes[human].gotoAndStop(2);
- if(motorstarted == false)
- {
- motorstarted = true;
- motorsnd.start(0,9999);
- }
- }
- }
- else
- {
- motorstarted = false;
- motorsnd.stop();
- }
- }
- xvel[human] *= friction;
- if(mode[human] == "ground")
- {
- if(keyb[human] != false)
- {
- if(key.isDown(38))
- {
- yvel[human] -= 0.9;
- }
- if(key.isDown(40))
- {
- yvel[human] += 0.9;
- }
- }
- yvel[human] *= friction * friction;
- bikes[human]._y += yvel[human];
- if(bikes[human]._y < track1._y)
- {
- bikes[human]._y = track1._y;
- yvel[human] = 0;
- }
- if(bikes[human]._y > track4._y)
- {
- bikes[human]._y = track4._y;
- yvel[human] = 0;
- }
- }
- obstacles._x -= xvel[human];
- back._x -= xvel[human] / 35;
- fondo.slide.clouds._x -= xvel[human] / 25;
- if(xvel[human] > 0 and bikes[human]._x > leftcenter or xvel[human] < 0 and bikes[human]._x < rightcenter)
- {
- bikes[human]._x -= xvel[human] / 2;
- }
- if(xvel[human] < 0)
- {
- if(obstacles._x > center * 2)
- {
- obstacles._x = - trackwidth;
- }
- if(back._x > center)
- {
- back._x -= back._width / 3;
- }
- if(fondo.slide.clouds._x > center)
- {
- fondo.slide.clouds._x -= fondo.slide.clouds._width / 3;
- }
- }
- else
- {
- if(obstacles._x < - trackwidth)
- {
- obstacles._x = center * 2 + 10;
- }
- if(back._x < center)
- {
- back._x += back._width / 3;
- }
- if(fondo.slide.clouds._x < center)
- {
- fondo.slide.clouds._x += fondo.slide.clouds._width / 3;
- }
- }
- if(seconds > 14 and sponsored == false and muchbikes > 2 and damage[human] < 80)
- {
- paused = sponsored = true;
- mafia.gotoAndPlay(2);
- }
- healingcounter++;
- if(healingcounter >= 15)
- {
- healingcounter = 0;
- b = 1;
- while(b <= muchbikes)
- {
- if(damage[b] > 1 and damage[b] < 100)
- {
- damagebike(b,-0.8);
- }
- if(b != human and mode[b] == "ground")
- {
- temp = random(20);
- if(temp == 0)
- {
- weapon[b] = weaponitems[random(4) + 1];
- useweapon(b);
- }
- else if(temp <= 2 and damage[b] < 40)
- {
- usextra(b);
- }
- }
- b++;
- }
- }
- b = 1;
- while(b <= muchbikes)
- {
- bikes[b].swapDepths(bikes[b]._y);
- bars[b].swapDepths(100 - kilpercent[b]);
- kilometer[b] += xvel[b];
- kilpercent[b] = Math.ceil(kilometer[b] * 100 / lap);
- bars[b].light.gotoAndStop(kilpercent[b]);
- if(bikes[b]._x > obstacles._x and kilpercent[b] > 100 and winnercounter[b] < 1)
- {
- bikes[b].chase.b.gotoAndStop("trick");
- winnercounter[b] = 1;
- keyb[b] = false;
- }
- if(b != human)
- {
- if(keyb[b] != false)
- {
- xvel[b] += engine[b];
- }
- xvel[b] *= friction;
- bikes[b]._x += xvel[b] - xvel[human];
- if(bikes[b]._x + obstacles._x > trackwidth + obstacles._x)
- {
- bikes[b]._x -= trackwidth;
- }
- if(bikes[b]._x < -100)
- {
- bikes[b]._x += trackwidth;
- }
- if(mode[b] == "ground" and keyb[b] != false)
- {
- if(random(60) == 0 and mytrackcounter[b] < 1)
- {
- mytrackcounter[b] = 1;
- mytrack[b] = eval("track" + Number(random(4) + 1))._y;
- }
- else if(mytrackcounter[b] > 0)
- {
- mytrackcounter[b]++;
- bikes[b]._y += (mytrack[b] - bikes[b]._y) / 20;
- if(mytrackcounter[b] > 20)
- {
- mytrackcounter[b] = 0;
- }
- }
- }
- }
- if(mode[b] == "falling")
- {
- if(b == human)
- {
- motorstarted = false;
- motorsnd.stop();
- }
- bikes[b]._y += yvel[b];
- yvel[b] += gravity;
- bikes[b].chase.b._rotation += Math.abs(xvel[b] / 30);
- if(bikes[b]._y > mytrack[b])
- {
- bikes[b].chase.b._rotation = 0;
- bikes[b]._y = mytrack[b];
- if(yvel[b] > 7)
- {
- bikes[b].chase.b.gotoAndPlay(1);
- yvel[b] = (- yvel[b]) * bounce;
- }
- else
- {
- mode[b] = "ground";
- yvel[b] = 0;
- }
- }
- }
- if(winnercounter[b] > 0)
- {
- if(mafiamission == b)
- {
- murdered();
- }
- if(b == human)
- {
- if(winnercounter[b] == 3)
- {
- playsound("newplayer");
- }
- if(mafiamission != false and mafiamission != "served")
- {
- murdered();
- }
- _xscale = _yscale = _yscale + (160 - _yscale) / 10;
- _Y = _Y + (-90 - _Y) / 10;
- _X = _X + (-100 - _X) / 10;
- }
- bars[b]._visible = false;
- bikes[b]._alpha -= 2;
- winnercounter[b]++;
- if(winnercounter[b] == 50)
- {
- arrived++;
- winner[arrived] = b;
- winnertime[arrived] = showtime;
- removeMovieClip(bikes[b]);
- playerstate[b] = "winner";
- mode[b] = "winner";
- if(arrived >= liveplayers or arrived >= 3 or b == human)
- {
- forcewinners();
- }
- }
- }
- else if(explodecounter[b] > 0)
- {
- keyb[b] = false;
- explodecounter[b]++;
- if(b == human)
- {
- motorsnd.stop();
- _xscale = _yscale = _yscale + (160 - _yscale) / 10;
- _Y = _Y + (-90 - _Y) / 10;
- _X = _X + (-100 - _X) / 10;
- }
- if(explodecounter[b] < 42)
- {
- bars[b]._visible = false;
- bikes[b].chase.b.explode.play();
- bikes[b].chase.b.gotoAndStop("trick");
- }
- else
- {
- if(b == human)
- {
- xtraface.gotoAndStop(1);
- weaponface.gotoAndStop(1);
- engineface.gotoAndStop(1);
- cauchoface.gotoAndStop(1);
- }
- bikes[b].chase.b.gotoAndStop("explode");
- if(explodecounter[b] == 150)
- {
- if(mafiamission == b)
- {
- mafiamission = "served";
- changemoney(mafiareward);
- paused = true;
- mafia.gotoAndPlay(2);
- }
- if(b == human and mafiamission != false and mafiamission != "served")
- {
- murdered();
- }
- }
- if(explodecounter[b] > 190)
- {
- playerstate[b] = "exploited";
- kilometer[b] = 0;
- liveplayers--;
- bikes[b]._visible = false;
- explodecounter[b] = kilometer[b] = 0;
- if(b == human)
- {
- xtra[human] = weapon[human] = null;
- cauchomodel[human] = engine[human] = 1;
- motor = "motor1";
- caucho = "caucho1";
- screen = "winners";
- forcewinners();
- }
- if(liveplayers <= 1)
- {
- forcewinners();
- }
- }
- }
- }
- else if(rampcounter[b] > 0)
- {
- rampcounter[b]++;
- if(xvel[b] > 0)
- {
- xvel[b] += 0.5;
- }
- else
- {
- xvel[b] -= 0.5;
- }
- if(rampcounter[b] > 45)
- {
- rampcounter[b] = 0;
- keyb[b] = true;
- }
- }
- else if(oilcounter[b] > 0)
- {
- if(b == human)
- {
- motorsnd.stop();
- }
- keyb[b] = false;
- rotatecounter[b]++;
- if(rotatecounter[b] > 2)
- {
- rotatecounter[b] = 0;
- if(bikes[b]._currentframe == 1)
- {
- bikes[b].gotoAndStop(2);
- }
- else
- {
- bikes[b].gotoAndStop(1);
- }
- }
- oilcounter[b]++;
- if(oilcounter[b] > 10)
- {
- oilcounter[b] = 0;
- ongroundcounter[b] = 1;
- }
- }
- else if(tachuelascounter[b] > 0)
- {
- if(b == human)
- {
- motorsnd.stop();
- }
- tachuelascounter[b]++;
- bikes[b].chase.b._rotation -= Math.abs(xvel[b] * 4);
- bikes[b].chase.b.gotoAndStop("trick");
- if(tachuelascounter[b] > 42)
- {
- bikes[b]._rotation = 0;
- tachuelascounter[b] = 0;
- ongroundcounter[b] = 1;
- }
- }
- else if(gumcounter[b] > 0)
- {
- bikes[b]._x += xvel[b];
- gumcounter[b]++;
- yvel[b] -= 0.2;
- bikes[b]._y += yvel[b];
- bikes[b].chase.b.gotoAndStop("gum");
- if(bikes[b]._x < gumcenter[b])
- {
- xvel[b] += 0.5;
- }
- else
- {
- xvel[b] -= 0.5;
- }
- bikes[b]._x += xvel[b];
- if(gumcounter[b] > 140)
- {
- gumcounter[b] = 0;
- yvel[b] = 0;
- bikes[b]._y = mytrack[b] - 80;
- mode[b] = "falling";
- bikes[b].chase.b.gotoAndPlay(1);
- bikes[b].stars.gotoAndPlay(2);
- keyb[b] = true;
- damagebike(b,20);
- }
- }
- else if(ongroundcounter[b] > 0)
- {
- if(b == human)
- {
- motorsnd.stop();
- }
- keyb[b] = false;
- bikes[b].chase.b.gotoAndStop("onground");
- ongroundcounter[b]++;
- if(ongroundcounter[b] > 60)
- {
- mytrack[b] = bikes[b]._y;
- bikes[b]._y -= 80;
- mode[b] = "falling";
- bikes[b].chase.b.gotoAndPlay(1);
- bikes[b].stars.gotoAndPlay(2);
- ongroundcounter[b] = 0;
- }
- }
- else if(poisoncounter[b] > 0)
- {
- poisoncounter[b]++;
- bikes[b].chase.b._rotation -= Math.abs(xvel[b] * 4);
- bikes[b].chase.b.gotoAndStop("trick");
- if(poisoncounter[b] > 62)
- {
- bikes[b]._rotation = 0;
- poisoncounter[b] = 0;
- ongroundcounter[b] = 1;
- }
- }
- o = 1;
- while(o <= muchbikes)
- {
- if(bikes[b]._x > -10)
- {
- if(bikes[b].chase.b.front.hitTest(bikes[o].chase.b.back))
- {
- damagebike(b,5);
- oilcounter[b]++;
- keyb[b] = false;
- }
- }
- o++;
- }
- o = 1;
- while(o <= tracklength)
- {
- obspos = obstacles[o]._x + obstacles._x;
- if(obspos < -300 or obspos > 700)
- {
- if(obstacles[o]._x < 0 or obstacles[o]._x > trackwidth)
- {
- obstacles[o].kind = "blank";
- }
- obstacles[o].gotoAndStop("blank");
- }
- else
- {
- kind = obstacles[o].kind;
- obstacles[o].gotoAndStop(kind);
- if(bikes[b]._x > -10)
- {
- if(mode[b] == "ground" and bikes[b].chase.b.front.hitTest(obstacles[o]))
- {
- obstacles[o][kind].snd.play();
- if(kind == "ramp")
- {
- mytrack[b] = bikes[b]._y;
- rampcounter[b]++;
- yvel[b] = -17;
- bikes[b]._y += yvel[b];
- bikes[b].chase.b._rotation = 325;
- bikes[b].chase.b.gotoAndStop("trick");
- mode[b] = "falling";
- }
- else if(kind == "jumper")
- {
- mytrack[b] = bikes[b]._y;
- rampcounter[b]++;
- xvel[b] *= 3;
- yvel[b] = -20;
- bikes[b]._y += yvel[b];
- bikes[b].chase.b._rotation = 325;
- bikes[b].chase.b.gotoAndStop("trick");
- mode[b] = "falling";
- }
- else if(kind == "dumb")
- {
- mytrack[b] = bikes[b]._y;
- xvel[b] *= 0.3;
- yvel[b] = -2;
- bikes[b].chase.b._rotation = random(10) - 5;
- mode[b] = "falling";
- }
- else if(kind == "grass")
- {
- xvel[b] *= 0.3;
- yvel[b] *= 0.1;
- }
- else if(kind == "oil")
- {
- obstacles[o][kind].play();
- damagebike(b,1);
- xvel[b] *= 1.1;
- oilcounter[b] = 1;
- keyb[b] = false;
- }
- else if(kind == "star")
- {
- if(bikes[b].chase.b.front.hitTest(obstacles[o].starbox.staranim.shadow))
- {
- obstacles[o].starbox.play();
- if(b == human and muchbikes > 1)
- {
- changemoney(10);
- }
- }
- }
- else if(kind == "banana")
- {
- damagebike(b,15);
- obstacles[o].kind = "blank";
- obstacles[o].banana.play();
- xvel[b] *= 1.1;
- oilcounter[b] = 1;
- keyb[b] = false;
- if(obstacles[o].human == true and b != human)
- {
- trace(b + " " + human);
- obstacles[o].human = false;
- changemoney(5);
- }
- }
- else if(kind == "poison")
- {
- if(bikes[b].chase.b.front.hitTest(obstacles[o].poison.box))
- {
- damagebike(b,40);
- mytrack[b] = bikes[b]._y;
- xvel[b] *= -15;
- yvel[b] = -20;
- poisoncounter[b] = 1;
- bikes[b].chase.b.desinfla.play();
- mode[b] = "falling";
- keyb[b] = false;
- obstacles[o].poison.play(2);
- if(obstacles[o].human == true and n != human)
- {
- obstacles[o].human = false;
- changemoney(20);
- }
- }
- }
- else if(kind == "gum")
- {
- obstacles[o].gum.play();
- mytrack[b] = bikes[b]._y;
- gumcenter[b] = bikes[b]._x - xvel[b] * 2;
- xvel[b] *= 0.3;
- gumcounter[b] = 1;
- keyb[b] = false;
- mode[b] = "gum";
- if(obstacles[o].human == true and n != human)
- {
- obstacles[o].human = false;
- changemoney(15);
- }
- }
- else if(kind == "tachuelas")
- {
- obstacles[o].tachuelas.play();
- damagebike(b,20);
- mytrack[b] = bikes[b]._y;
- xvel[b] *= -2;
- yvel[b] = -15;
- tachuelascounter[b] = 1;
- bikes[b].chase.b.desinfla.play();
- mode[b] = "falling";
- keyb[b] = false;
- if(obstacles[o].human == true and n != human)
- {
- obstacles[o].human = false;
- changemoney(10);
- }
- }
- }
- }
- }
- o++;
- }
- b++;
- }
- }
- };
- }
-